package request

import (
	"github.com/astaxie/beego/validation"
	"shop-common/utils"
	"shop-common/utils/pagehelper"
	"shop-common/utils/regular"
)

type SysLogSearchRequest struct {
	pagehelper.SearchPageRequest
	Data     string `json:"data" form:"data"`
	Path     string `json:"path" form:"path"`
	Terminal string `json:"terminal" form:"terminal"`
	Ip       string `json:"ip" form:"ip"`
	Method   string `json:"method" form:"method"`
}

func (s *SysLogSearchRequest) Valid(v *validation.Validation) {
	if !utils.StringIncludes([]string{"", "today", "yesterday", "lately7", "lately30", "month", "year"}, s.Data) {
		if !regular.IsTimeScope(s.Data) {
			v.SetError("Data", "选择时间不合法")
		}
	}
}
